package com.tree.backend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tree.backend.entity.SignalCollection;
import com.tree.backend.mapper.SignalCollectionMapper;
import com.tree.backend.service.ISignalCollectionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 信号数据采集表 服务实现类
 * </p>
 *
 * @author tree
 * @since 2025-10-24
 */
@Service
public class SignalCollectionServiceImpl extends ServiceImpl<SignalCollectionMapper, SignalCollection> implements ISignalCollectionService {

    @Override
    public List<Integer> getDeviceIds() {
        // 从设备表中获取所有设备ID
        QueryWrapper<SignalCollection> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("DISTINCT device_id");
        List<SignalCollection> signalCollections = this.list(queryWrapper);
        
        return signalCollections.stream()
                .map(SignalCollection::getDeviceId)
                .collect(Collectors.toList());
    }
}
